package org.p2psimulator.entity;

import org.p2psimulator.engine.Environment;
import org.p2psimulator.entity.protocol.Protocol;
import org.p2psimulator.entity.protocol.hibrid.eigentrust.EigenTrustProtocol;
import org.p2psimulator.entity.protocol.structured.ChordProtocol;
import org.p2psimulator.entity.protocol.structured.storm.StormProtocol;
import org.p2psimulator.entity.protocol.unstructured.FloodProtocol;
import org.p2psimulator.entity.protocol.unstructured.bayesian.BayesianProtocol;
import org.p2psimulator.entity.protocol.unstructured.p2prep.P2PRepProtocol;
import org.p2psimulator.entity.protocol.unstructured.xrep.XrepProtocol;

public enum ProtocolType {

    SUPERPEER, GNUTELLA, 
    XREP, P2PREP, BAYESIAN, 
    CHORD, EIGENTRUST, STORM;

    public Protocol getProtocol(Environment env) {
        if (this == GNUTELLA || this== SUPERPEER) {
            return new FloodProtocol(env);
        }
        if (this == CHORD) {
            return new ChordProtocol(env);
        }
        if (this == XREP) {
            return new XrepProtocol(env);
        }
        if (this == P2PREP) {
            return new P2PRepProtocol(env);
        }
        if (this == BAYESIAN) {
            return new BayesianProtocol(env);
        }

        if (this == EIGENTRUST) {

            return new EigenTrustProtocol(env);
        }
        if (this == STORM) {
            return new StormProtocol(env);
        }

        throw new IllegalArgumentException();
    }
}
